package com.dk.assertion;

import com.dk.domain.ApiAutoTestEntity;
import com.dk.util.log.Log;

/**
 * 断言链
 */
public abstract class AssertChain {
    //待执行的断言节点
    private AssertChain assertLink;

    public void setAssertChain(AssertChain assertLink){
        this.assertLink = assertLink;
    }

    public AssertChain getAssertChain(){
        return this.assertLink;
    }

    public ApiAutoTestEntity startAssert(ApiAutoTestEntity apiAutoTestEntity){
        assertBody(apiAutoTestEntity);
        if(this.assertLink!=null){
            this.assertLink.startAssert(apiAutoTestEntity);
        }else{
            Log.info("---【用例断言】:用例编号:"+apiAutoTestEntity.getCaseNum()+";用例名称:"+apiAutoTestEntity.getCaseName()+"-执行断言结束");
        }
        return apiAutoTestEntity;
    }

    /**
     * 断言执行类
     * @param apiAutoTestEntity 检查点对象
     * @return 断言结果
     */
    public abstract ApiAutoTestEntity assertBody(ApiAutoTestEntity apiAutoTestEntity);
}
